#ifndef SIMPLETIMER_H
#define SIMPLETIMER_H

#include "common.h"

class DLL SimpleTimer
{
public:
	typedef VOID (CALLBACK* TickProc)(SimpleTimer* sender, HWND hWnd, UINT_PTR idEvent, DWORD dwTime);
	
	SimpleTimer(HWND hWnd = 0);
	~SimpleTimer();

	void Start();
	void Stop();
	void SetInterval(UINT interval);
	UINT GetInterval();
	bool IsRunning();
	void SetTag(LPVOID tag);
	LPVOID GetTag();
	void Tick(TickProc ptr);
private:
	LPVOID tag;
	HWND hWnd;
	UINT timerID;
	UINT interval;
	bool running;
	TickProc onTickPtr;

	static map<UINT, SimpleTimer*> instances;
	static UINT instanceID;
	static VOID CALLBACK TimerProc(HWND hWnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime);
};

#endif
